home *** CD-ROM | disk | FTP | other *** search
- unit MainForm;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, OleServer, Outlook8, Outlook, PipeServer;
-
- type
- THelperMainForm = class(TForm)
- HelperActive: TCheckBox;
- Label1: TLabel;
- Log: TMemo;
- FreeObjects: TButton;
- ClearLog: TButton;
- procedure FormCreate(Sender: TObject);
- procedure ClearLogClick(Sender: TObject);
- procedure FreeObjectsClick(Sender: TObject);
- private
- { Private declarations }
- pstThread : TPipeServerThread;
- Procedure SendObjectFreeCommand;
- public
- { Public declarations }
- Procedure LogMessage(strMessage : String);
- end;
-
- var
- HelperMainForm: THelperMainForm;
-
- implementation
-
- {$R *.DFM}
-
- Procedure THelperMainForm.LogMessage(strMessage : String);
- Begin
- Log.Lines.Insert(0,DateTimeToStr(Now)+': '+strMessage+'.');
- End;
-
- procedure THelperMainForm.FormCreate(Sender: TObject);
- begin
- pstThread := TPipeServerThread.Create(False);
- end;
-
- Procedure THelperMainForm.SendObjectFreeCommand;
- Var
- hPipe : THandle;
- iBW : Cardinal; { bytes written, bytes read }
-
- Begin
- {
- The FREE command is sent so that the pipe server thread can properly shut down.
- This is needed because otherwise the connection to Outlook will persist even
- though this application has been closed. Simply closing the application
- won't properly terminate the thread as ConnectNamedPipe is a blocking function.
- }
- hPipe := CreateFile(strPipeName,Generic_Write,0,nil,Open_Existing,0,0);
- WriteFile(hPipe,'FREE',4,iBW,nil);
- CloseHandle(hPipe);
- End;
-
- procedure THelperMainForm.ClearLogClick(Sender: TObject);
- begin
- Log.Clear;
- end;
-
- procedure THelperMainForm.FreeObjectsClick(Sender: TObject);
- begin
- pstThread.Terminate;
- SendObjectFreeCommand;
- end;
-
- end.
-